#ifndef DATA_STREAM_H
#define DATA_STREAM_H
#include <string.h>
#include <stdlib.h>

typedef int datastream_size_t;

/**
 * simple structure
 * holding an array of bytes
 */
typedef struct dataStream_t
	{
	/** array of bytes */
	char* data;
	/** length of data */
	datastream_size_t size;
	/** vector capacity */
	datastream_size_t capacity;
	}DataStreamStructure,*DataStream;




/** create a new DataStream */
extern DataStream DataStreamNew();
/** free a  DataStream */
extern void DataStreamFree(DataStream ptr);
/** append the bytes to the end of the DataStream returns 1 on success 0 on failure */
extern int DataStreamAppend(DataStream ptr,const char*,datastream_size_t);
/** append the byte to the end of the DataStream returns 1 on success on failure */
extern int DataStreamAppendC(DataStream ptr,char);
/** size of the buffer */
extern datastream_size_t DataStreamSize(const DataStream ptr);
/** access to the buffer */
extern const char* DataStreamData(const DataStream ptr);

/** structure holding a position for reading a DataStream */
typedef struct DSReader_t
	{
	DataStream in;
	int position;
	}DSReaderStructure,*DataStreamReader;
/** try to read exactly n bytes for the DataStream
  returns 1 and advance the cursor on success 0 on failure */
int DataStreamRead(DataStreamReader in,char* buffer,datastream_size_t);

#endif

